<?php
class Zenddn_Validator_ValidatePrivileges{
    
    protected $_isNotExists = true;
    
    public function __construct($module, $controller, $action){
    	$validateModule = new Zend_Validate();
        $validateController = new Zend_Validate();
        $validateAction = new Zend_Validate();
        
        $option = array('table' => 'privileges', 'field' => 'module');
        $validateModule->addValidator(new Zend_Validate_Db_RecordExists($option));
        
        $option = array('table' => 'privileges', 'field' => 'controller');
        $validateController->addValidator(new Zend_Validate_Db_RecordExists($option));
        
        $option = array('table' => 'privileges', 'field' => 'action');
        $validateAction->addValidator(new Zend_Validate_Db_RecordExists($option));
        
        if($validateAction->isValid($action) && $validateController->isValid($controller) && $validateModule->isValid($module)){
            $this->_isNotExists = false;
        }
    }
    
    public function isValid(){
    	return $this->_isNotExists;
    }
}